<template>
  <div>
    <customDialog
      :title="'回传设置'"
      :dialogVisible="dialogVisible"
      :showCancel="false"
      @close="dialogVisible = false"
      @confirm="confirm"
      width="850"
    >
      <returnTemp
        v-if="id"
        ref="returnTempRef"
        :isDefaultTemp="'promotion'"
        :id="id"
      />
    </customDialog>
  </div>
</template>

<script lang="ts" setup>
import { ref, reactive } from "vue";
import returnTemp from "@/components/ReturnSetting/index.vue";

const returnTempRef = ref();
const dialogVisible = ref(false);
const id = ref();

// 成功
const emit = defineEmits(["success"]);
const confirm = async () => {
  // 获取子组件的form表单对象
  let formRef = returnTempRef.value.ruleFormRef;
  if (formRef) {
    // 拿到子组件弹窗回调事件后 再关闭弹窗
    let temp = await returnTempRef.value.confirmDialog(formRef);
    if (temp) {
      dialogVisible.value = false;
      emit("success");
    }
  }
};

// 父级电子显示dialog
const showDialog = (val: Record<string, any>) => {
  // console.log("回传信息", val);
  id.value = val?.id;
  dialogVisible.value = true;
};

defineExpose({
  showDialog,
});
</script>
<style scoped lang="scss">
.price_box {
  :deep(.el-form-item__error) {
    padding-left: 141px;
  }
}

.nums_box {
  :deep(.el-form-item__error) {
    padding-left: 159px;
  }
}

.inputWidth_130 {
  width: 130px;
}

.inputWidth_50 {
  width: 60px;
}
</style>
